package logic;
import java.util.Iterator;
import java.util.List;

import data.IActivityDAO;
import data.JDBCActivityDAO;

public class ActivityStore {
		
	    IActivityDAO act = new JDBCActivityDAO();
	    private static ActivityStore actList;
		private List<Activity> activities; 
		
		public static synchronized ActivityStore getInstance(){
			if(actList == null){
				actList = new ActivityStore();
			}
			return actList;
		}
		
	    private ActivityStore() {
	        activities = (new JDBCActivityDAO()).selectAll();
	    }

	    public List<Activity> getActivities() {
	        return activities;
	    }

	    public Activity getActivity(String activityID) {
	        Activity result = null;
	        for (Iterator<Activity> iter = activities.iterator(); iter.hasNext();) {
	            Activity a = (Activity) iter.next();
	            if (a.getId().compareTo(activityID) == 0) {
	                result = a;
	            }
	        }
	        return result;
	    }
	    
	    public List<Activity> getMostPopularActivities(){
	    	return act.selectMostPopularActivities();
	    }
	    
	    
	    public List<Activity> getFavouriteActivities(String userId){
	    	return act.selectFavouriteActivities(userId);
	    }
	    public List<Activity> selectRecentActivities(String destinationId){
	    	return act.selectRecentActivities(destinationId);
	    }
	    
	    public List<Activity> selectActivitiesFromDestination(String destinationId){
	    	
	    	return act.selectActivitiesFromDestination(destinationId);
	    	
	    }
	    public List<Activity> newActivityFind(List<String> l) {
	    	
	    	return act.newActivityFind(l);
	    	
	    }
	    
	    public List<String> getTypes(){
	    	return act.getTypes();
	    }
	    
	}



